﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using TomanuExtensions;

namespace AmiEmuLib.AmigaConfiguration.MountedDevicesConfig
{
    /// <summary>
    /// Represent a harddrive which is directory in host.
    /// </summary>
    public class Filesystem : MountedDevice
    {
        /// <summary>
        /// Path to harddrive directory.
        /// </summary>
        public string DirectoryPath = "";

        /// <summary>
        /// This name is usedin workbench. Because we don't use harddisk image 
        /// we must provide that name.
        /// </summary>
        public string VolumeName = "";

        /// <summary>
        /// Constructor.
        /// </summary>
        public Filesystem()
        {
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="a_reader"></param>
        public Filesystem(XmlReader a_reader)
            : base(a_reader)
        {
        }

        protected override void ReadXml(XmlReader a_reader)
        {
            a_reader.ReadStartElement(GetType().Name);

            base.ReadXml(a_reader);

            DirectoryPath = a_reader.ReadElementContentAsString("DirectoryPath");
            VolumeName = a_reader.ReadElementContentAsString("VolumeName");

            a_reader.ReadEndElement();
        }

        public override void WriteXml(XmlWriter a_writer)
        {
            a_writer.WriteStartElement(GetType().Name);

            base.WriteXml(a_writer);

            a_writer.WriteElement("DirectoryPath", DirectoryPath);
            a_writer.WriteElement("VolumeName", VolumeName);

            a_writer.WriteEndElement();
        }
    }
}
